import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '@/views/HomeView'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    name: 'homeview',
    component: HomeView,
  },
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: "/HomeHistory",
    name: 'homeHistory',
    component: () => import('@/views/HomeView/HomeHistory')
  },
  {
    path: "/hotAndNewView",
    name: 'HotAndNewView',
    component: () => import('@/views/HomeView/HotAndNewView')
  },
  {
    path: "/homecategory",
    name: 'HomeCategory',
    component: () => import('@/views/HomeView/HomeCategory')
  },
  {
    path: "/homemap",
    name: 'HomeMap',
    component: () => import('@/views/HomeView/HomeMap')
  },

  {
    path: '/topic',
    name: 'topicview',
    component: () => import('@/views/TopicView')
  },
  {
    path: '/topicDetail',
    name: 'TopicDetail',
    component: () => import('@/views/TopicView/TopicDetail')
  },

  {
    path: '/category',
    name: 'CategoryView',
    component: () => import('@/views/CategoryView')
  },

  {
    path: '/categoryDetail',
    name: 'CategoryDetail',
    component: () => import('@/views/CategoryView/CategoryDetail')
  },
  {
    path: '/goodsDetail',
    name: 'GoodsDetail',
    component: () => import('@/views/CategoryView/GoodsDetail')
  },
  {
    path: '/cart',
    name: 'CartView',
    component: () => import('@/views/CartView')
  },
  {
    path: '/pay',
    name: 'PayView',
    component: () => import('@/views/CartView/PayView')
  },
  {
    path: '/user',
    name: 'UserView',
    component: () => import('@/views/UserView')
  },
  {
    path: '/user/address',
    name: 'AddressView',
    component: () => import('@/views/UserView/AddressView')
  },
  {
    path: '/user/collection',
    name: 'UserCollection',
    component: () => import('@/views/UserView/UserCollection')
  },
  {
    path: '/user/feedback',
    name: 'UserFeedback',
    component: () => import('@/views/UserView/UserFeedback')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { y: 0 }
  },
})

export default router
